package com.soft.mapper;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.soft.entity.Dept;
import com.soft.entity.Sushe;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class SusheMapperTest {
	@Autowired
	private SusheMapper susheMapper;
	//@Test
	public void testSelect()
	{
		List<Sushe> susheList = susheMapper.selectList(null);
		for(int i = 0;i < susheList.size();i++)
		{
			System.out.println(susheList.get(i).getSusheFloor());
		}
	}
	//@Test
	public void testinsert() {
	    Sushe sushe = new Sushe();
	    sushe.setSusheFloor("san楼");
	    sushe.setSusheCapacity("hxasux二");
	    susheMapper.insert(sushe);
	}
	//@Test
	public void updateTest() {
	    Sushe sushe = new Sushe();
	    sushe.setSusheSno("1");
	    sushe.setSusheFloor("aaaa");
	    sushe.setSusheCapacity("aaaa");
	    susheMapper.updateById(sushe);
	}
    @Test
    public void updateQueryTest()
    {
    	QueryWrapper<Sushe> uw = new QueryWrapper();
        uw.gt("sushe_sno", 2);
        Sushe sushe = new Sushe();
        sushe.setSusheCapacity("acuc");
        susheMapper.update(sushe,uw);
        int num = susheMapper.update(sushe,uw);
        System.out.println(num);
    }
	//@Test
	public void deleteTest() {
		Sushe sushe = new Sushe();
	    sushe.setSusheSno("2");
	    susheMapper.deleteById(sushe);
	}
	//@Test
	public void deleteQueryTest()
	{
		QueryWrapper<Sushe> qw = new QueryWrapper();
		qw.eq("sushe_floor", "aaaa");
		susheMapper.delete(qw);
	}
	//@Test
		public void selectIdTest()
		{
			Sushe sushe = susheMapper.selectById(7);
			System.out.println(sushe.getSusheFloor());
		}
	@Test
	public void selectOneTest() {
		QueryWrapper<Sushe> qw = new QueryWrapper<>();
		qw.gt("sushe_sno", 8);
		try
		{
			Sushe sushe = susheMapper.selectOne(qw);
			System.out.println(sushe);
		}catch(Exception e)
		{
			System.out.println("用户名和密码重复，请修改密码");
		}

	}
}
